
do 99_programs.do

use ../data/c8290hh_reg_main, clear

** Table A1: determinants of twinning

est clear
eststo: qui reg twinhh age2birthP2 i.birthyP2 i.prov i.wave, cluster(prov_edulevP2)
eststo: qui reg twinhh age2birthP2 eduyP2 i.birthyP2 i.prov i.wave, cluster(prov_edulevP2)
eststo: qui reg twinhh age2birthP2 eduyP2 eduyP1 i.birthyP2 i.prov i.wave, cluster(prov_edulevP2)
eststo: qui reg twinhh age2birthP2 eduyP2 eduyP1 male i.birthyP2 i.prov i.wave, cluster(prov_edulevP2)
eststo: qui reg twinhh age2birthP2 eduyP2 eduyP1 male fine3b i.birthyP2 i.prov i.wave, cluster(prov_edulevP2)
eststo: qui reg twinhh age2birthP2 eduyP2 eduyP1 male fine3b i.birthyP2 i.prov i.wave prov*_birthyP2, cluster(prov_edulevP2)
local kvars "age2birthP2 eduyP2 eduyP1 male fine3b "
esttab using ../output/TableA1_tabTwinRandom.csv, ///
keep(`kvars')  /// 
order(`kvars') ///
b(5) se(5) star(* .10 ** .05 *** .01) stats(N r2, labels("Observations"  "R-squared" ) fmt(0 3)) ///
title("Rural second-born twins") nogaps label n replace


** Table 3: baseline and placebo

est clear

local ctrl1 = " age2birthP2 male age age2 i.edulevP2  i.prov i.birthyP2 i.wave prov*_birthyP2 "
local ctrl = " `ctrl1'  "
eststo: bootstrap _b beta_diff = (_b[beta_B] - _b[beta_A]), ///
seed(123) rep(100) cluster(prov_edulevP2) strata(prov) : reg_nchild3_edulev3 `ctrl'

local ctrl1_nomale = " age2birthP2 age age2 i.edulevP2 i.prov i.birthyP2 i.wave prov*_birthyP2 "
local ctrl = " `ctrl1_nomale'  "
eststo: bootstrap _b beta_diff = (_b[beta_B] - _b[beta_A]), ///
seed(123) rep(100) cluster(prov_edulevP2) strata(prov) : reg_nchild3_edulev3_bymale `ctrl'

local ctrl1_noedu = " age2birthP2 age age2  i.prov i.birthyP2 i.wave prov*_birthyP2 "
local ctrl = " `ctrl1_noedu'  "
eststo: bootstrap _b beta_diff = (_b[beta_B] - _b[beta_A]), ///
seed(123) rep(100) cluster(prov_edulevP2) strata(prov) : reg_nchild3_edulev3_byeduyP2dm `ctrl'


local kvars "alpha_z alpha_zx alpha_x rho_z rho_zx rho_x beta_A beta_B alpha_sum beta_diff r2_fs r2_rf "
esttab using ../output/Table3_tabBaslinePlacebo.csv, ///
keep(`kvars')  /// 
order(`kvars') ///
b(3) se(3) star(* .10 ** .05 *** .01) stats(N, labels("Observations") fmt(0)) ///
title("Rural second-born twins") nogaps label n replace


	* first-stage F-statistic
est clear

local ctrl1 = " age2birthP2 male age age2 i.edulevP2  i.prov i.birthyP2 i.wave prov*_birthyP2 "
local ctrl = " `ctrl1'  "
eststo: bootstrap, seed(123) rep(100) cluster(prov_edulevP2) strata(prov): reg_nchild3 `ctrl'
test twinhh fine3b_twinhh, df(104)
estadd scalar F = r(F)

local ctrl1_nomale = " age2birthP2 age age2 i.edulevP2 i.prov i.birthyP2 i.wave prov*_birthyP2 "
local ctrl = " `ctrl1_nomale'  "
eststo: bootstrap, seed(123) rep(100) cluster(prov_edulevP2) strata(prov): reg_nchild3_bymale `ctrl'
test twinhh male_twinhh, df(104)
estadd scalar F = r(F)

local ctrl1_noedu = " age2birthP2 age age2  i.prov i.birthyP2 i.wave prov*_birthyP2 "
local ctrl = " `ctrl1_noedu'  "
eststo: bootstrap, seed(123) rep(100) cluster(prov_edulevP2) strata(prov): reg_nchild3_byeduyP2dm `ctrl'
test twinhh eduyP2dm_twinhh, df(104)
estadd scalar F = r(F)

local kvars "twinhh   fine3b_twinhh fine3b   male_twinhh male   eduyP2dm_twinhh eduyP2dm  "
esttab using ../output/Table3_tabBaslinePlacebo_F.csv, ///
keep(`kvars')  /// 
order(`kvars') ///
b(3) se(3) star(* .10 ** .05 *** .01) stats(F N, labels("F-statistic" "Observations") fmt(2 0)) ///
title("Rural second-born twins") nogaps label n replace






** Table A5: pretrends
local ctrl1 = " age2birthP2 male age age2 i.edulevP2  i.prov i.birthyP2 i.wave prov*_birthyP2 "

est clear

local ctrl = " `ctrl1' prov*_year2 "
eststo: bootstrap _b beta_diff = (_b[beta_B] - _b[beta_A]), ///
seed(123) rep(100) cluster(prov_edulevP2) strata(prov) : reg_nchild3_edulev3 `ctrl'

local ctrl = " `ctrl1' i.birthyP2#c.gdpg_dm "
eststo: bootstrap _b beta_diff = (_b[beta_B] - _b[beta_A]), ///
seed(123) rep(100) cluster(prov_edulevP2) strata(prov) : reg_nchild3_edulev3 `ctrl'

local ctrl = " `ctrl1' i.birthyP2#c.popGrowth_dm "
eststo: bootstrap _b beta_diff = (_b[beta_B] - _b[beta_A]), ///
seed(123) rep(100) cluster(prov_edulevP2) strata(prov) : reg_nchild3_edulev3 `ctrl'

local kvars "alpha_z alpha_zx alpha_x rho_z rho_zx rho_x beta_A beta_B alpha_sum beta_diff r2_fs r2_rf "
esttab using ../output/TableA5_pretrend.csv, ///
keep(`kvars')  /// 
order(`kvars') ///
b(3) se(3) star(* .10 ** .05 *** .01) stats(N, labels("Observations") fmt(0)) ///
title("Rural second-born twins") nogaps label n replace


	* first-stage F-statistic
est clear

local ctrl = " `ctrl1' prov*_year2 "
eststo: bootstrap, seed(123) rep(100) cluster(prov_edulevP2) strata(prov): reg_nchild3 `ctrl'
test twinhh fine3b_twinhh, df(104)
estadd scalar F = r(F)

local ctrl = " `ctrl1' i.birthyP2#c.gdpg_dm "
eststo: bootstrap, seed(123) rep(100) cluster(prov_edulevP2) strata(prov): reg_nchild3 `ctrl'
test twinhh fine3b_twinhh, df(104)
estadd scalar F = r(F)

local ctrl = " `ctrl1' i.birthyP2#c.popGrowth_dm "
eststo: bootstrap, seed(123) rep(100) cluster(prov_edulevP2) strata(prov): reg_nchild3 `ctrl'
test twinhh fine3b_twinhh, df(104)
estadd scalar F = r(F)

local kvars "twinhh fine3b_twinhh fine3b "
esttab using ../output/TableA5_pretrend_F.csv, ///
keep(`kvars')  /// 
order(`kvars') ///
b(3) se(3) star(* .10 ** .05 *** .01) stats(F N, labels("F-statistic" "Observations") fmt(2 0)) ///
title("Rural second-born twins") nogaps label n replace





** Table A6: robustness to confounders

local ctrl1 = " age2birthP2 male age age2 i.edulevP2 i.prov i.birthyP2 i.wave prov*_birthyP2  "

est clear

local ctrl = " `ctrl1' llfExp3b "
eststo: bootstrap _b beta_diff = (_b[beta_B] - _b[beta_A]), ///
seed(123) rep(100) cluster(prov_edulevP2) strata(prov) : reg_nchild3_edulev3 `ctrl'

local ctrl = " `ctrl1' cel "
eststo: bootstrap _b beta_diff = (_b[beta_B] - _b[beta_A]), ///
seed(123) rep(100) cluster(prov_edulevP2) strata(prov) : reg_nchild3_edulev3 `ctrl'

local ctrl = " `ctrl1' nteacherSecondary "
eststo: bootstrap _b beta_diff = (_b[beta_B] - _b[beta_A]), ///
seed(123) rep(100) cluster(prov_edulevP2) strata(prov) : reg_nchild3_edulev3 `ctrl'

local ctrl = " `ctrl1' i.birthyP2#c.lnsdyReceivedRatio_dm "
eststo: bootstrap _b beta_diff = (_b[beta_B] - _b[beta_A]), ///
seed(123) rep(100) cluster(prov_edulevP2) strata(prov) : reg_nchild3_edulev3 `ctrl'

local ctrl = " `ctrl1' i.birthyP2#c.lnlossratio_dm "
eststo: bootstrap _b beta_diff = (_b[beta_B] - _b[beta_A]), ///
seed(123) rep(100) cluster(prov_edulevP2) strata(prov) : reg_nchild3_edulev3 `ctrl'

local ctrl = " `ctrl1' i.birthyP2#c.lnCRdratio_dm "
eststo: bootstrap _b beta_diff = (_b[beta_B] - _b[beta_A]), ///
seed(123) rep(100) cluster(prov_edulevP2) strata(prov) : reg_nchild3_edulev3 `ctrl'


local kvars "alpha_z alpha_zx alpha_x rho_z rho_zx rho_x beta_A beta_B alpha_sum beta_diff r2_fs r2_rf "
esttab using ../output/TableA6_robust.csv, ///
keep(`kvars')  /// 
order(`kvars') ///
b(3) se(3) star(* .10 ** .05 *** .01) stats(N r2, labels("Observations"  "R-squared" ) fmt(0 3)) ///
title("Rural second-born twins") nogaps label n replace


	* first-stage F-statistic
est clear

local ctrl = " `ctrl1' llfExp3b c.llfExp3b_dm#c.twinhh "
eststo: bootstrap, seed(123) rep(100) cluster(prov_edulevP2) strata(prov): reg_nchild3 `ctrl'
test twinhh fine3b_twinhh, df(104)
estadd scalar F = r(F)

local ctrl = " `ctrl1' cel c.cel#c.twinhh "
eststo: bootstrap, seed(123) rep(100) cluster(prov_edulevP2) strata(prov): reg_nchild3 `ctrl'
test twinhh fine3b_twinhh, df(104)
estadd scalar F = r(F)

local ctrl = " `ctrl1' nteacherSecondary "
eststo: bootstrap, seed(123) rep(100) cluster(prov_edulevP2) strata(prov): reg_nchild3 `ctrl'
test twinhh fine3b_twinhh, df(104)
estadd scalar F = r(F)

local ctrl = " `ctrl1' i.birthyP2#c.lnsdyReceivedRatio_dm "
eststo: bootstrap, seed(123) rep(100) cluster(prov_edulevP2) strata(prov): reg_nchild3 `ctrl'
test twinhh fine3b_twinhh, df(104)
estadd scalar F = r(F)

local ctrl = " `ctrl1' i.birthyP2#c.lnlossratio_dm "
eststo: bootstrap, seed(123) rep(100) cluster(prov_edulevP2) strata(prov): reg_nchild3 `ctrl'
test twinhh fine3b_twinhh, df(104)
estadd scalar F = r(F)

local ctrl = " `ctrl1' i.birthyP2#c.lnCRdratio_dm "
eststo: bootstrap, seed(123) rep(100) cluster(prov_edulevP2) strata(prov): reg_nchild3 `ctrl'
test twinhh fine3b_twinhh, df(104)
estadd scalar F = r(F)

local kvars "twinhh fine3b_twinhh fine3b "
esttab using ../output/TableA6_robust_F.csv, ///
keep(`kvars')  /// 
order(`kvars') ///
b(3) se(3) star(* .10 ** .05 *** .01) stats(F N, labels("F-statistic" "Observations") fmt(2 0)) ///
title("Rural second-born twins") nogaps label n replace



